<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    class task_m extends CI_Model {
        function get_all_tasks() {
            $q = $this->db->get('task');
            if($q->num_rows() > 0) {
                return $q->result_array();
            }else{
                return FALSE;
            }
        }
        
        function get_task($coord_id){
            $q = $this->db->where('coord_id',$coord_id)->get('task');
            if($q->num_rows()>0){
                return $q->result_array();
            }else{
                return FALSE;
            }
        }
                
        function insert_task($data) {
            $this->db->insert('task', $data);
            return $this->db->insert_id();
        }
        
        function  update_task($task_id, $data) {
            $this->db->where('task_id', $task_id)->update('task', $data);
        }
        
        function delete_task($task_id){
            $this->db->where('task_id', $task_id)->delete('task');
            return $this->db->affected_rows();
        }
    }
